<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="../assets/js/vue.js"></script>
    <link rel="stylesheet" href="../assets/css/index.css"/>
</head>
<body>
<h1>mixins</h1>
<hr>
<div id="app">
    {{message}}
    {{message2}}
    <p><button @click="jia">+</button></p>
</div>

<script>
    Vue.mixin({
        created:function () {
            console.log('我是全局被混入的')
        }
    })

    var aaa={
        data: {
            message: 'mixins',
            message2: 'mixins222'
        },
        created:function () {
            this.message="我被混入了"
            console.log('我是被混入的')
        },
        methods:{
            jia:function () {
                console.log('加了,混入的')
            }
        }
    }
    var vm = new Vue({
        el: '#app',
        data: {//data会覆盖混入的,重名的
            message: 'hello Vue'
        },
        methods:{//methods会覆盖混入的
          jia:function () {
              console.log('加了')
          }
        },
        created:function () {//生命周期不会覆盖，先执行混入的
            console.log('我是构造器里的')
        },
        mixins:[aaa]
    })
</script>
</body>
</html>